package com.budwk.app.miniapp.models;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import com.budwk.starter.common.openapi.annotation.ApiModel;
import com.budwk.starter.common.openapi.annotation.ApiModelProperty;
import com.budwk.starter.database.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;

/**
 * 用户app与openid关系记录业务对象 wx_user_relation
 *
 * @author dfxy
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Table("wx_user_relation")
@ApiModel(description = "用户app与openid关系记录业务对象 wx_user_relation")
public class WxUserRelation extends BaseModel implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * $column.columnComment
     */
    @Id(auto=false)
    @Column
    @Comment("id")
    @ApiModelProperty(description = "id")
    @Prev(els=@EL("$me.nextId()"))
    @ColDefine(type = ColType.INT, width = 64)
    private Long id;

    /**
     * $column.columnComment
     */
    @Column("user_id")
    @Comment("用户ID")
    @ApiModelProperty(description = "用户ID")
    @ColDefine(type = ColType.VARCHAR, width = 64)
    private String userId;

    /**
     * $column.columnComment
     */
    @Column("open_id")
    @Comment("用户ID")
    @ApiModelProperty(description = "用户ID")
    @ColDefine(type = ColType.VARCHAR, width = 64)
    private String openId;

    /**
     * $column.columnComment
     */
    @Column("app_type")
    @Comment("应用类型")
    @ApiModelProperty(description = "应用类型")
    @ColDefine(type = ColType.VARCHAR, width = 64)
    private String appType;

    public Long nextId() {
        String id=IdUtil.getSnowflake(1, 1).nextIdStr();
        return NumberUtil.parseLong(id);
    }
}
